var input1 = 0;
var input2 = 0;
var utils = require('../../utils/util.js');
Page({
  data: {
    unit: [['Unit 01', 'Unit 02', 'Unit 03', 'Unit 04', 'Unit 05', 'Unit 06', 'Unit 07', 'Unit 08', 'Unit 09', 'Unit 10', 'Unit 11', 'Unit 12'], ['Passage 01', 'Passage 02','Passage 03']],
    index:[0,0],
  },
  change:function(e){

    console.log(e)
    this.setData({index:e.detail.value})
    console.log(this.data.index)
    
  },
  input:e=>{
    if(e.currentTarget.id=='1'){input1 = e.detail.value}
    else{input2 = e.detail.value}
  },
  
  tap: function (e) {
    var key = arr[this.data.index[0]][this.data.index[1]]
    wx.showModal({
      title: '确定上传信息？',
      content: '数据写入请谨慎',
      success:e=>{if(e.confirm){
    wx.showModal({
      title: this.data.unit[0][this.data.index[0]]+' '+this.data.unit[1][this.data.index[1]]+'密钥为：',
      content: key,
    })
    console.log(utils.formatTime(new Date()))
    console.log(this.data.unit[0][this.data.index[0]], this.data.unit[1][this.data.index[1]])
    console.log(input1)
    console.log(input2)
    wx.request({
      url: 'http://118.25.179.118/secret.php',
      data: {
        flag: 'w',
        date: utils.formatTime(new Date()),
        unit: this.data.unit[0][this.data.index[0]] + ' ' + this.data.unit[1][this.data.index[1]],
        radio: input1,
        mains: input2,
        key:key
      },
      success: e => {
        console.log(e.data)
      }
    })
    }}})
  },
  log: function (e) {
    wx.request({
      url: 'http://118.25.179.118/secret.php',
      data: {
        flag: 'r',
      },
      success: e => {
        console.log(e)
        getApp().globalData.log=e.data
        wx.navigateTo({
          url: '../log/log',
        })
      }
    })
  },
})

var arr = [
  [
    '75PHIU',
    '07VTBL',
    '87KZXB',
  ],
  [
   '93OUBP',
   '42QRHH',
   '88PLYG',
  ],
  [
   '69GOCL',
   '60PCCV',
   '20HKIZ',
  ],
  [
    '94HEER',
    '44TIRF',
    '15CMYH',
  ],
  [
    '73HYRQ',
    '40PSYW',
    '05YLSN',
  ],
  [
    '54JKHB',
    '29BKJN',
    '14GQOE',
  ],
  [
    '96NKCV',
    '47QWAF',
    '01IDAO',
  ],
  [
    '65WCFS',
    '43ETZO',
    '07KMNF',
  ],
  [
    '30PEZC',
    '42XUHS',
    '20AIVI',
  ],
  [
    '24GJBN',
    '28PUZI',
    '50RLZD',
  ],
  [
    '96JEMF',
    '91AJOY',
    '54WWST',
  ],
  [
    '93NLSE',
    '45VOLN',
    '26NSXK',
  ]
]